<template>
  <div class="page">
    <u-navbar title="自提列表">
      <div slot="right" @click="handleClickAddShopAddress" class="right">
        添加
      </div>
    </u-navbar>
    <div class="global-list" v-if="addressData.length != 0">
      <div class="global-item" @click="handleClick(item)" v-for="(item,index) in addressData" :key="index">
        <div class="flex global-top-col">
          <div class="global-sn">{{item.addressName}}</div>
        </div>
        <div class="flex goods-item">
          <div class="wes-2 goods-name">{{item.address}}</div>
        </div>
        <div class="global-bottom-col flex">
          <div class="global-createTime">{{item.createTime}}</div>
        </div>
      </div>
    </div>

  </div>
</template>

<script>
import { getShopAddress } from "@/api/shops";

export default {
  data() {
    return {
      addressData: [], //自提列表
      current: 0,
      searchForm: {
        // 搜索框初始化对象
        pageNumber: 1, // 当前页数
        pageSize: 10, // 页面大小
      },
    };
  },

  methods: {
    onShow() {
      this.addressData = [];
      this.searchForm.pageNumber = 1;
      this.init();
    },
    onReachBottom() {
      this.searchForm.pageNumber++;
      this.init();
    },

    handleClickAddShopAddress() {
      uni.navigateTo({
        url: `/pages/other/setup/shopAddressDetail`,
      });
    },

    handleClick(val) {
     
      uni.navigateTo({
        url: `/pages/other/setup/shopAddressDetail?data=${encodeURIComponent(
          JSON.stringify(val)
        )}`,
      });
    },

    load() {
      this.searchForm.pageNumber = 1;
      this.addressData = [];
      this.init();
    },
    async init() {
      uni.showLoading({
        title: "加载中",
      });

      let res = await getShopAddress(this.searchForm);
      if (res.data.success) {
        this.addressData.push(...res.data.result.records);
      }

      uni.hideLoading();
    },
  },
};
</script>
<style scoped>
page {
  background: #f6f6f6;
}
</style>
<style lang="scss" scoped>
@import "@/components/global.scss";
.goods-name {
  margin: 0;
}
.delete {
  color: $main-color;
}
.right {
  margin-right: 32rpx;
}
</style>